package seven.three;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Partitioner;

import seven.entity.OrderBean;

public class ItemIdPartitioner extends Partitioner<OrderBean,NullWritable>{

	@Override
	public int getPartition(OrderBean bean, NullWritable arg1, int num) {
		//相同id的订单bean,会发往相同的partiton
		//而且产生的分区数，是会跟用户设置的reduce task数保持一致
		return (bean.getItemId().hashCode() & Integer.MAX_VALUE) % num;
	}
	
}
